﻿app.controller("ngAccountController", function ($scope) {
    $scope.Account = function () { }
    $scope.show = function (i) {
        //alert(i);
        $scope.ShowAddGame = false;
        $scope.ShowRentals = false;
        $scope.YourGames = false;
        $scope.YourProfile = false;
        if (i == 1) {
            $scope.YourProfile = true;
        } else if (i == 2) {
            $scope.YourGames = true;
        } else if (i == 3) {
            $scope.ShowRentals = true;
        } else if (i == 4) {
            $scope.ShowAddGame = true;
        }
    }
});

app.controller("ngAddGameController", function ($scope, $http, $location, GameList) {
    console.log("add game controller");
    $scope.addingGame = false;
    $scope.game;
    //$scope.saveGame = function (game) {
    //    console.log("hello")
    //    $http.post("/api/game", game).success(function (data) {

    //        game = data;
    //        $location.path("#/GameIndex");
    //    }).error(function (data) {
    //        alert("Error adding!")
    //        $location.path("/");
    //    });
    //};

    $scope.showGameForm = function (newGame) {
        console.log("adding");
        $scope.newGame = newGame;
        $scope.newGame.SellPrice = 0.00;
        $scope.newGame.RentPrice = 0.00;
        $scope.newGame.WillTrade = false;

        $scope.addingGame = true;
    };

    $scope.addGame = function (newGame) {
        $http.post("/api/game", newGame).success(function (data) {
            console.log("showing games");
            $scope.show(2);
        });
    }

    $scope.azGames;

    $http.get("/api/az").success(function (data) {
        $scope.azGames = data;
    }).error(function (data) {
        console.log(JSON.stringify(data));
    });

});